kruskalWallisTestDialog <- function(){
	initializeDialog(title=gettextRcmdr("Kruskal-Wallis Rank Sum Test"))
	groupBox <- variableListBox(top, Factors(), title=gettextRcmdr("Groups (pick one)"))
	responseBox <- variableListBox(top, Numeric(), title=gettextRcmdr("Response Variable (pick one)"))
	optionsFrame <- tkframe(top)
	pairwiseVariable <- tclVar("0")
	pairwiseCheckBox <- tkcheckbutton(optionsFrame, variable=pairwiseVariable)
	onOK <- function(){
		group <- getSelection(groupBox)
		if (length(group) == 0) {
			errorCondition(recall=KruskalWallisTestDialog, message=gettextRcmdr("You must select a groups variable."))
			return()
		}
		response <- getSelection(responseBox)
		closeDialog()
		if (length(response) == 0) {
			errorCondition(recall=KruskalWallisTestDialog, message=gettextRcmdr("You must select a response variable."))
			return()
		}
		.activeDataSet <- ActiveDataSet()
		doItAndPrint(paste("tapply(", paste(.activeDataSet, "$", response, sep=""),
						", ", paste(.activeDataSet, "$", group, sep=""), ", median, na.rm=TRUE)", sep=""))
		doItAndPrint(paste("kruskal.test(", response, " ~ ", group, ", data=", .activeDataSet, ")", sep=""))
		pairwise <- tclvalue(pairwiseVariable)
		if (pairwise == 1) {
			doItAndPrint(paste("kruskalMultipleComparison(", .activeDataSet, "$", response, ",", .activeDataSet, "$", group, ")", sep=""))
		}
		tkfocus(CommanderWindow())
	}
	OKCancelHelp(helpSubject="kruskal.test")
	tkgrid(getFrame(groupBox), getFrame(responseBox), sticky="nw")
	tkgrid(labelRcmdr(optionsFrame, text=gettext("Pairwise comparisons", domain="R-RcmdrPlugin.TeachingExtras")), pairwiseCheckBox, sticky="w")
	tkgrid(optionsFrame, sticky="w", columnspan=2)
	tkgrid(buttonsFrame, columnspan=2, sticky="w")
	dialogSuffix(rows=2, columns=2)
}